package com.pet.system.security.shiro;

import com.pet.system.domain.model.LoginUser;
import com.pet.system.security.jwt.JwtTools;
import com.pet.system.utils.SpringContextUtil;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * SecurityUtils
 *
 * @author Centaurea
 */
public class SecurityUtils {

  /**
   * 获取当前登录用户
   *
   * @return
   */
  public static LoginUser getLoginUser() {
    ServletRequestAttributes servletRequestAttributes =
        (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = servletRequestAttributes.getRequest();

    JwtTools jwtTools = SpringContextUtil.getBean(JwtTools.class);
    return jwtTools.getLoginUser(request);
  }

  /** 登出 */
  public static void logout() {}
}
